package com.woniu.map.remote.url;

import com.alibaba.nacos.shaded.com.google.common.base.Optional;
import com.woniu.internalcommon.constant.AmapConfigConstants;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.util.UriComponentsBuilder;

@Service
public class WeatherUrl {

    @Value("${map.key}")
    private String mapKey;

    /**
     *
     * @param city 地理编码
     * @param isForecast 是否是预报
     * @return
     */
    public String buildWeatherUrl(String city,
                                  Boolean isForecast){
       // ?city=110100&key=7367d4e858a51c328ce549ac315007d0
        return UriComponentsBuilder
                .fromHttpUrl(AmapConfigConstants.WEATHER_URL)
                .queryParam("city",city)
                .queryParam( "key",mapKey)
                .queryParam( "extensions",
                        isForecast? "all" : "base")
                .toUriString();
     }


}
